package com.ian.offer;


import com.ian.linked.TreeNode;

/**
 * @author zhangyaowen
 * @date 2021/2/21 9:19 上午
 */
public class MirrorTree {

    public TreeNode mirrorTree(TreeNode root) {
        swap(root);

        return root;
    }


    private void swap(TreeNode node) {

        if (node == null) {
            return;
        } else {
            swap(node.left);
            swap(node.right);
        }

        TreeNode left = node.left;
        TreeNode right = node.right;
        node.right = left;
        node.left = right;


    }
}
